<template>
<div class="password">
	<Button type="primary" @click="passwordSave">保存</Button><br><br>
<Row>
<Col span="8">
	<Form ref="form" :model="baseform" :rules="rule" :label-width="100">
		<FormItem label="原密码" prop="str1">
			<Input type="password" v-model="baseform.str1"></Input>
		</FormItem>
		<FormItem label="新密码" prop="str2">
			<Input type="password" password v-model="baseform.str2"></Input>
		</FormItem>
		<FormItem label="确认新密码" prop="str3">
			<Input type="password" password v-model="baseform.str3"></Input>
		</FormItem>
	</Form>
</Col>
</Row>
</div>
</template>

<script>
import config from '@/config'
export default {
	data(){
		return {
			baseform:{
				str1:'',
				str2:'',
				str3:''
			},
			rule:{
				str1:[
					{ required: true, message: '密码不能为空', trigger: 'blur' }
				],
				str2:[
					{ required: true, message: '密码不能为空', trigger: 'blur' }
				],
				str3:[
					{ required: true, message: '密码不能为空', trigger: 'blur' }
				]
			}
		}
	},
	computed:{
	},
	methods:{
		passwordSave(){
			 this.$refs.form.validate((valid) => {
				this.baseform.str4=sessionStorage.getItem("uid")
				if (valid) {
					this.$axios.post('passwordEdit.action',this.baseform).then(res=>{
						if(res.data==='fail'){
							this.$Message.error('原密码不正确');
						}else if(res.data==='no'){
							this.$Message.error('新密码两次不一致');
						}else if(res.data==='suc'){
							this.$Modal.info({
								title: "密码重置成功",
								content: "请重新登录",
								onOk:()=>{
									sessionStorage.clear()
									this.$router.push('/')
								}
							});
						}
					})
				}
			})
		}
	}
}
</script>

<style scoped>
.password{
	padding:16px ;
}
</style>